// test.ts
import { v4 as uuidv4 } from "uuid";
import { MockMethod, MockConfig } from "vite-plugin-mock";
import Mock from "mockjs";

const Random = Mock.Random;

export default [
  {
    url: "/api/project",
    method: "post",
    timeout: 1000,
    response: () => {
      const dataList: any[] = [];
      const count = 15; // 假设我们想要生成5个数据项

      for (let i = 0; i < count; i++) {
        dataList.push({
          id: uuidv4(),
          user_id: uuidv4(),
          title: Random.cword(5, 25),
          description: Random.cparagraph(),
          // purchased: Mock.mock({
          //   "boolean|1-2": true,
          // }).boolean, // 是否被购买
          pic: Random.image("3484x2531", "#4A7BF7", "vue&react&laravel"),
          type: "动漫人物类",
          useTechnology: Random.cword(5, 55), // 技术栈
          salesVolume: Mock.mock({
            // 销量
            "number|1-100": 100,
          }).number,
          price: Mock.mock({
            // 价格
            "number|1-100": 100,
          }).number,
          oldPrice: Mock.mock({
            // 旧价格
            "number|1-300": 200,
          }).number,
          isNew: Mock.mock({
            // 是否为最近上新
            "boolean|1-2": true,
          }).boolean,
        });
      }
      return {
        code: 0,
        msg: "请求成功",
        type: "success",
        data: dataList,
      };
    },
  },
  {
    url: "/api/project/:id",
    method: "get",
    timeout: 1000,
    response: () => {
      const picList = Array.from({ length: Random.integer(3, 10) }, () => {
        // return Random.image("3484x2531", "#4A7BF7", Random.cword(1, 4)); // 生成随机图片，图片内容关键词随机
        return "http://dummyimage.com/3484x2531/4A7BF7&text=html";
      });
      return {
        code: 0,
        msg: "请求成功",
        type: "success",
        data: {
          id: uuidv4(),
          user_id: uuidv4(),
          title: Random.cword(5, 25),
          description: Random.cparagraph(),
          // purchased: Mock.mock({
          //   "boolean|1-2": true,
          // }).boolean, // 是否被购买
          discover: Random.image("3484x2531", "#4A7BF7", "html"),
          picList: [
            "https://dummyimage.com/600x400/000/fff",
            "http://dummyimage.com/3484x2531/4A7BF7&text=html",
            "https://dummyimage.com/600x400/000/fff",
            "http://dummyimage.com/3484x2531/4A7BF7&text=html",
            "https://dummyimage.com/600x400/000/fff",
            "http://dummyimage.com/3484x2531/4A7BF7&text=html",
            "https://dummyimage.com/600x400/000/fff",
            "http://dummyimage.com/3484x2531/4A7BF7&text=html",
            "https://dummyimage.com/600x400/000/fff",
            "http://dummyimage.com/3484x2531/4A7BF7&text=html",
            "https://dummyimage.com/600x400/000/fff",
            "http://dummyimage.com/3484x2531/4A7BF7&text=html",
            "https://dummyimage.com/600x400/000/fff",
            "http://dummyimage.com/3484x2531/4A7BF7&text=html",
            "https://dummyimage.com/600x400/000/fff",
            "http://dummyimage.com/3484x2531/4A7BF7&text=html",
          ],
          videoUrl:
            "https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/2minute-demo.mp4",
          type: "动漫人物类",
          tips: "升级账号即可以下载全站所有源码",
          useTechnology: Random.cword(5, 55), // 技术栈
          salesVolume: Mock.mock({
            // 销量
            "number|1-100": 100,
          }).number,
          price: Mock.mock({
            // 价格
            "number|1-100": 100,
          }).number,
          oldPrice: Mock.mock({
            // 旧价格
            "number|1-300": 200,
          }).number,
          isNew: Mock.mock({
            // 是否为最近上新
            "boolean|1-2": true,
          }).boolean,
        },
      };
    },
  },
] as MockMethod[];
